home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 7 / BBS in a Box - Macintosh - Volume VII (BBS in a Box) (January 1993).iso / Files / Tele / Pete Johnson / Flip 1.0.3<source>.cpt / Flip.p next >
Text File  |  1991-06-23  |  20KB  |  760 lines

  1. program Flip;
  2.  
  3. {    Version 1.0.3                                                                                    }
  4. {                                                                                                    }
  5. {    Program written by Pete Johnson for the Glassell Park BBS • (213) 254-4133.        }
  6. {    Reads script to send files out to Fido nodes.                                                }
  7. {                                                                                                    }
  8. {    Release notes:                                                                                }
  9. {    V 1.0 released for about a day 12/1/90.                                                    }
  10. {    V 1.01 (12/2/90) fixes occasional sending of script file.                                }
  11. {    V 1.02 (5/30/91) adds SIZE resource.                                                        }
  12. {    V 1.0.3 (6/23/91) removes CloseWD call.                                                    }
  13.  
  14.     uses
  15.         FlipGlobals, HelloTabby, TxWrite, WriteMsg;
  16.  
  17.     type
  18.         DayOfWeek = (Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, EveryDay);
  19.  
  20.     const
  21.         MaxOldies = 40;
  22.  
  23.     var
  24.         WhereAt, DataFileName, Location, When, RegisterSTR, OwnerName, Unreg: str255;
  25.         OldiesCount, FileCount, SendToCount: integer;
  26.         SendFiles: array[1..10] of string[32];
  27.         SendTo: array[1..10] of string[16];
  28.         FilesProcessed: array[1..MaxOldies] of string[32];
  29.         RunDialog: DialogPtr;
  30.         GoodName: boolean;
  31.  
  32. { ------------------------------------------------------ }
  33.  
  34.     function StringToDay (DayString: str255): DayOfWeek;
  35.  
  36.     begin
  37.         uprString(DayString, false);
  38.         if pos('SUN', DayString) = 1 then
  39.             StringToDay := Sunday
  40.         else if pos('MON', DayString) = 1 then
  41.             StringToDay := Monday
  42.         else if pos('TUE', DayString) = 1 then
  43.             StringToDay := Tuesday
  44.         else if pos('WED', DayString) = 1 then
  45.             StringToDay := Wednesday
  46.         else if pos('THU', DayString) = 1 then
  47.             StringToDay := Thursday
  48.         else if pos('FRI', DayString) = 1 then
  49.             StringToDay := Friday
  50.         else if pos('SAT', DayString) = 1 then
  51.             StringToDay := Saturday
  52.         else
  53.             StringToDay := EveryDay
  54.     end;
  55.  
  56. {-----------------------------------------------------------------    }
  57.  
  58.     function DayToString (Day: DayOfWeek): str255;
  59.  
  60.     begin
  61.         case Day of
  62.             Sunday: 
  63.                 DayToString := 'Sunday';
  64.             Monday: 
  65.                 DayToString := 'Monday';
  66.             Tuesday: 
  67.                 DayToString := 'Tuesday';
  68.             Wednesday: 
  69.                 DayToString := 'Wednesday';
  70.             Thursday: 
  71.                 DayToString := 'Thursday';
  72.             Friday: 
  73.                 DayToString := 'Friday';
  74.             Saturday: 
  75.                 DayToString := 'Saturday';
  76.             otherwise
  77.                 DayToString := 'Every Day'
  78.         end
  79.     end;
  80.  
  81. {-----------------------------------------------------------------    }
  82.  
  83.     function WhatDay: DayOfWeek;
  84.  
  85.         var
  86.             Today: DateTimeRec;
  87.  
  88.     begin
  89.         GetTime(Today);
  90.         case Today.dayOfWeek of
  91.             1: 
  92.                 WhatDay := Sunday;
  93.             2: 
  94.                 WhatDay := Monday;
  95.             3: 
  96.                 WhatDay := Tuesday;
  97.             4: 
  98.                 WhatDay := Wednesday;
  99.             5: 
  100.                 WhatDay := Thursday;
  101.             6: 
  102.                 WhatDay := Friday;
  103.             otherwise
  104.                 WhatDay := Saturday
  105.         end
  106.     end;
  107.  
  108. {-----------------------------------------------------------------    }
  109.  
  110.     procedure FrameDItem (dLog: DialogPtr; iNum: integer);
  111.  
  112.         var
  113.             iBox: Rect;
  114.             iType: integer;
  115.             iHandle: Handle;
  116.             oldPenState: PenState;
  117.  
  118.     begin
  119.         GetPenState(oldPenState);
  120.         GetDItem(dLog, iNum, iType, iHandle, iBox);
  121.         InsetRect(iBox, -4, -4);
  122.         PenSize(3, 3);
  123.         FrameRoundRect(iBox, 16, 16);
  124.         SetPenState(oldPenState)
  125.     end;
  126.  
  127. {-----------------------------------------------------------------    }
  128.  
  129.     procedure myCloseWD;
  130.  
  131.         var
  132.             counter: integer;
  133.             myWDPBRec: WDPBRec;
  134.  
  135.     begin
  136.         counter := 0;
  137.         repeat
  138.             counter := succ(counter);
  139.             with myWDPBRec do
  140.                 begin
  141.                     ioCompletion := nil;
  142.                     ioWDProcID := mySignature;
  143.                     ioWDIndex := counter;
  144.                     ioVRefNum := 0;
  145.                 end;
  146.             Err := PBGetWDInfo(@myWDPBRec, false);
  147.             if Err = noErr then
  148.                 Err := PBCloseWD(@myWDPBRec, false);
  149.         until Err <> noErr
  150.     end;
  151.  
  152. {-----------------------------------------------------------------    }
  153.  
  154.     procedure MakePath (FName: STR255; VRefNum: integer; var MyPath: STR255);
  155.  
  156.         var
  157.             MyPB: CInfoPBRec;
  158.  
  159.     begin
  160.         MyPath := '';
  161.         MyPB.ioCompletion := nil;
  162.         MyPB.ioNamePtr := @FName;
  163.         MyPB.ioVRefNum := VRefNum;
  164.         MyPB.ioFDirIndex := 0;
  165.         MyPB.ioDirID := 0;
  166.         Err := PBGetCatInfo(@MyPB, false);
  167.         MyPB.ioFDirIndex := -1;
  168.         MyPB.ioDirID := MyPB.ioDRParID;
  169.         while PBGetCatInfo(@MyPB, false) = NoErr do
  170.             begin
  171.                 MyPath := concat(MyPB.ioNamePtr^, ':', MyPath);
  172.                 MyPB.ioDirID := MyPB.ioDRParID;
  173.                 MyPB.ioFDirIndex := -1;
  174.             end;        {    while PBGetCatInfo(@MyPB, false) = NoErr    }
  175.     end;
  176.  
  177. { ------------------------------------------------------ }
  178.  
  179.     procedure FitToASCII (var Check: integer);
  180.  
  181.     begin
  182.         Check := Check mod 126;
  183.         if Check < 32 then
  184.             Check := Check + 32
  185.     end;
  186.  
  187. { ------------------------------------------------------ }
  188.  
  189.     procedure VerifyRegistration;
  190.  
  191.         var
  192.             Check1, Check2, Check3, Check4, Check5, Counter: integer;
  193.  
  194.     begin
  195.         Check1 := 0;
  196.         Check2 := 0;
  197.         GoodName := true;
  198.         OwnerName := copy(RegisterSTR, 1, length(RegisterSTR) - 5);
  199.         for Counter := 1 to length(OwnerName) do
  200.             begin
  201.                 Check1 := Check1 + (ord(OwnerName[Counter]) mod 51);
  202.                 Check2 := Check2 + Counter;
  203.             end;
  204.         Check3 := (length(OwnerName) * ord(OwnerName[length(OwnerName)]));
  205.         Check4 := ord(RegisterSTR[length(RegisterSTR) - 1]);
  206.         FitToASCII(Check1);
  207.         FitToASCII(Check2);
  208.         FitToASCII(Check3);
  209.         Check5 := Check1 + Check2 + Check3 + Check4;
  210.         FitToASCII(Check5);
  211.  
  212.         if (ord(RegisterSTR[length(RegisterSTR) - 4]) <> Check1) then
  213.             GoodName := false
  214.         else if (ord(RegisterSTR[length(RegisterSTR) - 3]) <> Check2) then
  215.             GoodName := false
  216.         else if (ord(RegisterSTR[length(RegisterSTR) - 2]) <> Check3) then
  217.             GoodName := false
  218.         else if (ord(RegisterSTR[length(RegisterSTR)]) <> Check5) then
  219.             GoodName := false;
  220.         if not GoodName then
  221.             OwnerName := Unreg
  222.     end;
  223.  
  224. {-----------------------------------------------------------------    }
  225.  
  226.     procedure Configure;
  227.  
  228.         var
  229.             theDialog: DialogPtr;
  230.             ItemHit, itemType, fRef: integer;
  231.             DelayTime: longint;
  232.             dispRect: Rect;
  233.             itemHandle: Handle;
  234.             where, leftLine, rightLine: point;
  235.             fileReply: SFReply;
  236.             whatToFind: SFTypeList;
  237.             TempString: str255;
  238.  
  239. {----------}
  240.  
  241.         procedure FlashButton (WhichButton: integer);
  242.  
  243.         begin
  244.             getDItem(theDialog, WhichButton, itemType, itemHandle, dispRect);
  245.             InsetRect(dispRect, 1, 1);
  246.             InvertRect(dispRect);
  247.             if StillDown then
  248.                 repeat
  249.                 until not Button
  250.             else
  251.                 Delay(4, DelayTime);
  252.             Delay(4, DelayTime)
  253.         end;
  254.  
  255. {----------}
  256.  
  257.         procedure DrawBox (ItemNo: integer; Info: str255);
  258.  
  259.         begin
  260.             ForeColor(RedColor);
  261.             getDItem(theDialog, ItemNo, itemType, itemHandle, dispRect);
  262.             SetIText(itemHandle, Info);
  263.             ForeColor(BlueColor);
  264.             insetRect(dispRect, -1, -1);
  265.             FrameRect(dispRect)
  266.         end;
  267.  
  268. {----------}
  269.  
  270.         procedure Refresh;
  271.  
  272.         begin
  273.             ForeColor(BlueColor);
  274.             TextFont(Geneva);
  275.             TextSize(9);
  276.             PenPat(Gray);
  277.             getDItem(theDialog, 18, itemType, itemHandle, dispRect);
  278.             SetIText(itemHandle, concat('version ', VERSION, ' of ', compdate));
  279.  
  280.             ForeColor(RedColor);
  281.             getDItem(theDialog, 14, itemType, itemHandle, dispRect);        {    user item for © info    }
  282.             MoveTo(dispRect.left, dispRect.bottom - 2);
  283.             DrawString('©1990 by Pete Johnson. All rights reserved.');
  284.  
  285.             DrawBox(3, NextLaunch);
  286.             DrawBox(4, DataFileName);
  287.             DrawBox(5, Location);
  288.             DrawBox(16, When);
  289.             DrawBox(17, OwnerName);
  290.  
  291.             PenPat(Black);
  292.             ForeColor(BlackColor);
  293.             FrameDItem(theDialog, Ok)
  294.         end;
  295.  
  296. {----------}
  297.  
  298.     begin
  299.         InitCursor;
  300.  
  301.         Err := FSOpen(concat(gDefaultpath, 'Flip ID'), vRefNum, fRef);
  302.         if Err = NoErr then
  303.             begin
  304.                 Err := ReadALine(fRef, RegisterSTR);
  305.                 VerifyRegistration;
  306.                 RmveResource(GetResource('STR ', 504));
  307.                 UpdateResFile(CurResFile);
  308.                 AddResource(Handle(NewString(RegisterSTR)), 'STR ', 504, 'Registration')
  309.             end;
  310.         Err := FSClose(fRef);
  311.  
  312.         theDialog := GetNewDialog(500, nil, POINTER(-1));
  313.         SetPort(theDialog);
  314.  
  315.         if StillDown then
  316.             repeat
  317.             until not Button;
  318.  
  319.         DrawDialog(theDialog);
  320.         Refresh;
  321.  
  322.         repeat
  323.             ModalDialog(nil, ItemHit);
  324.  
  325.             case ItemHit of
  326.                 1: { OK button hit -- save resources }
  327.                     begin
  328.                         getDItem(theDialog, 3, itemType, itemHandle, dispRect);
  329.                         GetIText(itemHandle, NextLaunch);
  330.                         RmveResource(GetResource('STR ', 500));
  331.                         UpdateResFile(CurResFile);
  332.                         AddResource(Handle(NewString(NextLaunch)), 'STR ', 500, 'Next Launch');
  333.  
  334.                         getDItem(theDialog, 4, itemType, itemHandle, dispRect);
  335.                         GetIText(itemHandle, DataFileName);
  336.                         RmveResource(GetResource('STR ', 501));
  337.                         UpdateResFile(CurResFile);
  338.                         AddResource(Handle(NewString(DataFileName)), 'STR ', 501, 'Data File');
  339.  
  340.                         getDItem(theDialog, 5, itemType, itemHandle, dispRect);
  341.                         GetIText(itemHandle, Location);
  342.                         RmveResource(GetResource('STR ', 502));
  343.                         UpdateResFile(CurResFile);
  344.                         AddResource(Handle(NewString(Location)), 'STR ', 502, 'Location');
  345.  
  346.                         getDItem(theDialog, 16, itemType, itemHandle, dispRect);
  347.                         GetIText(itemHandle, When);
  348.                         When := DayToString(StringToDay(When));
  349.                         RmveResource(GetResource('STR ', 503));
  350.                         UpdateResFile(CurResFile);
  351.                         AddResource(Handle(NewString(When)), 'STR ', 503, 'When');
  352.                     end;
  353.  
  354.                 6: 
  355.                     begin { Look Up Next Launch button        }
  356.                         FlashButton(6);
  357.                         InvertRect(dispRect);
  358.                         where.h := 60;
  359.                         where.v := 80;
  360.                         whatToFind[0] := 'APPL';
  361.                         ParamText('default application to launch', '', '', '');
  362.                         SFGetFile(where, '', nil, 1, whatToFind, nil, fileReply);
  363.                         if fileReply.good then
  364.                             NextLaunch := fileReply.fName;
  365.                         Refresh
  366.                     end;
  367.  
  368.                 7: 
  369.                     begin { Look Up Log Path button        }
  370.                         FlashButton(7);
  371.                         InvertRect(dispRect);
  372.                         where.h := 60;
  373.                         where.v := 80;
  374.                         SFPutFile(where, 'Please select file location ', 'test.$', nil, fileReply);
  375.                         if fileReply.good then
  376.                             begin
  377.                                 Err := Create(fileReply.fname, fileReply.vRefNum, 'QED1', 'TEXT');
  378.                                 MakePath(fileReply.fname, fileReply.vRefNum, Location);
  379.                                 Err := FSDelete(fileReply.fname, fileReply.vRefNum);
  380.                                 getDItem(theDialog, 5, itemType, itemHandle, dispRect);
  381.                                 SetIText(itemHandle, Location)
  382.                             end;
  383.                         Refresh
  384.                     end;
  385.  
  386.                 8: 
  387.                     begin
  388.                         FlashButton(8);
  389.                         InvertRect(dispRect);
  390.                         getDItem(theDialog, 16, itemType, itemHandle, dispRect);
  391.                         When := DayToString(pred(StringToDay(When)));
  392.                         Refresh
  393.                     end;
  394.  
  395.                 9: 
  396.                     begin
  397.                         FlashButton(9);
  398.                         InvertRect(dispRect);
  399.                         getDItem(theDialog, 16, itemType, itemHandle, dispRect);
  400.                         if (StringToDay(When) = EveryDay) then
  401.                             When := DayToString(Sunday)
  402.                         else
  403.                             When := DayToString(succ(StringToDay(When)));
  404.                         Refresh
  405.                     end;
  406.  
  407.                 16: 
  408.                     begin
  409.                         FlashButton(16);
  410.                         When := DayToString(EveryDay);
  411.                         Refresh
  412.                     end;
  413.  
  414.                 20: 
  415.                     begin { Look Up Info File button        }
  416.                         FlashButton(20);
  417.                         InvertRect(dispRect);
  418.                         where.h := 60;
  419.                         where.v := 80;
  420.                         whatToFind[0] := 'TEXT';
  421.                         ParamText('info file to use', '', '', '');
  422.                         SFGetFile(where, '', nil, 1, whatToFind, nil, fileReply);
  423.                         if fileReply.good then
  424.                             DataFileName := fileReply.fName;
  425.                         Refresh
  426.                     end;
  427.  
  428.                 otherwise
  429.                     ;    {    do nothing    }
  430.  
  431.             end            {    case statement    }
  432.         until (ItemHit = 1) or (ItemHit = 2);
  433.  
  434.         DisposDialog(theDialog)
  435.     end;
  436.  
  437. { ------------------------------------------------------ }
  438.  
  439.     procedure GetGenericPath;
  440.  
  441. {    returns path to Generic Folder ending in colon or else empty string        }
  442.  
  443.         var
  444.             GenericID: integer;
  445.  
  446.     begin
  447.         Err := FSOpen(concat(gDefaultpath, 'Generic'), vRefNum, GenericID);
  448.         if Err = NoErr then
  449.             begin
  450.                 Err := ReadALine(GenericID, GenericPath);
  451.                 Err := FSClose(GenericID)
  452.             end
  453.         else
  454.             GenericPath := ''
  455.     end;
  456.  
  457. { ------------------------------------------------------ }
  458.  
  459.     procedure ForwardFile (TheFile: str255);
  460. {    send file to recipients, add it to end of FilesProcessed array        }
  461.  
  462.         var
  463.             Counter, fRef: integer;
  464.             fName: str255;
  465.  
  466.     begin
  467.         for Counter := 1 to SendToCount do
  468.             begin
  469.                 fName := concat(GenericPath, 'sendfiles', SendTo[Counter], '.bbs');
  470.                 MakeTextFile(fName);
  471.                 Err := FSOpen(fName, vRefNum, fRef);
  472.                 if Err = NoErr then
  473.                     begin
  474.                         Err := SetFPos(fRef, fsFromLEOF, 0);
  475.                         if Err = NoErr then
  476.                             Err := WrLn(fRef, concat(Location, TheFile));
  477.                         SendMessage(SendTo[Counter], OwnerName, TheFile)
  478.                     end;
  479.                 Err := FSClose(fRef)
  480.             end;        {    for Counter := 1 to SendToCount    }
  481.         if OldiesCount < MaxOldies then
  482.             begin
  483.                 OldiesCount := succ(OldiesCount);
  484.                 FilesProcessed[OldiesCount] := TheFile
  485.             end
  486.         else
  487.             begin
  488.                 for Counter := 20 to 2 do
  489.                     FilesProcessed[Counter] := FilesProcessed[Counter - 1];
  490.                 FilesProcessed[1] := TheFile
  491.             end
  492.     end;
  493.  
  494. { ------------------------------------------------------ }
  495.  
  496.     procedure LookFor (MagicName: str255; myWDPB: WDPBRec);
  497.  
  498.         var
  499.             CheckPB: CInfoPBRec;
  500.             Count, Index: integer;
  501.             Result, NewFile: boolean;
  502.             TempString: str255;
  503.  
  504.     begin
  505.         uprString(MagicName, false);
  506.         Count := 1;
  507.         repeat
  508.             WhereAt := Location;
  509.             CheckPB.ioNamePtr := @WhereAt;
  510.             CheckPB.ioFDirIndex := Count;
  511.             CheckPB.ioCompletion := nil;
  512.             CheckPB.iovRefNum := MyWDPB.iovRefNum;
  513.             CheckPB.ioDrDirID := 0;
  514.             Err := PBGetCatInfo(@CheckPB, false);
  515.             if (Err = NoErr) & not (BitTst(@CheckPB.ioFlAttrib, 3)) then        {    make sure it's a file, not a folder    }
  516.                 begin
  517.                     NewFile := false;
  518.                     TempString := CheckPB.ioNamePtr^;
  519.                     uprString(TempString, false);
  520.                     if (pos(MagicName, TempString) = 1) | ((pos(MagicName, '*') = 1) & (length(MagicName) = 1)) then
  521.                         begin
  522.                             if not (EqualString(TempString, DataFileName, false, false)) then
  523.                                 begin
  524.                                     NewFile := true;
  525.                                     for Index := 1 to OldiesCount do
  526.                                         begin
  527.                                             if (EqualString(FilesProcessed[Index], TempString, false, false)) then
  528.                                                 begin
  529.                                                     NewFile := false;
  530.                                                     leave
  531.                                                 end        {    if (EqualString(FilesProcessed[Index], TempString, false, false))    }
  532.                                         end        {    for Index := 1 to OldiesCount                                            }
  533.                                 end;        {    if not (EqualString(TempString, DataFileName, false, false))            }
  534.                             if NewFile then
  535.                                 ForwardFile(CheckPB.ioNamePtr^)
  536.                         end        {    contains MagicName or is * )}
  537.                 end;
  538.             Count := succ(Count)
  539.         until (Err <> NoErr)
  540.     end;
  541.  
  542. { ------------------------------------------------------ }
  543.  
  544.     procedure Verify (var MagicName: str255; myWDPB: WDPBRec);
  545.  
  546.         var
  547.             CheckPB: CInfoPBRec;
  548.             Count, Index: integer;
  549.             StillExists: boolean;
  550.  
  551.     begin
  552.         uprString(MagicName, false);
  553.         Count := 1;
  554.         StillExists := false;
  555.         repeat
  556.             WhereAt := Location;
  557.             CheckPB.ioNamePtr := @WhereAt;
  558.             CheckPB.ioFDirIndex := Count;
  559.             CheckPB.ioCompletion := nil;
  560.             CheckPB.iovRefNum := MyWDPB.iovRefNum;
  561.             CheckPB.ioDrDirID := 0;
  562.             Err := PBGetCatInfo(@CheckPB, false);
  563.             if (Err = NoErr) then
  564.                 if not (BitTst(@CheckPB.ioFlAttrib, 3)) then        {    make sure it's a file, not a folder    }
  565.                     if (EqualString(MagicName, CheckPB.ioNamePtr^, false, false)) then
  566.                         StillExists := true;
  567.             Count := succ(Count)
  568.         until (Err <> NoErr) | (StillExists = true);
  569.         if (not StillExists) then
  570.             MagicName := ''
  571.     end;
  572.  
  573. { ------------------------------------------------------ }
  574.  
  575.     procedure ReadInfo;
  576.  
  577.         const
  578.             FileMode = 1;
  579.             SendToMode = 2;
  580.             OldiesMode = 3;
  581.  
  582.         var
  583.             Counter, InfoFile: integer;
  584.             TempString: str255;
  585.             Mode: integer;
  586.  
  587.     begin
  588.         for Counter := 1 to 10 do
  589.             begin
  590.                 SendFiles[Counter] := '';
  591.                 SendTo[Counter] := '';
  592.             end;
  593.         for Counter := 1 to MaxOldies do
  594.             FilesProcessed[Counter] := '';
  595.         FileCount := 1;
  596.         SendToCount := 1;
  597.         OldiesCount := 1;
  598.         Mode := FileMode;
  599.         Err := FSOpen(concat(Location, DataFileName), vRefNum, InfoFile);
  600.         if Err = NoErr then
  601.             while (not AtEOF(InfoFile)) do
  602.                 begin
  603.                     Err := ReadALine(InfoFile, TempString);
  604.                     if (TempString[1] <> ';') then    {    ignore remarks    }
  605.                         begin
  606.                             if not ((TempString[1] = '•') & (length(TempString) = 1)) then
  607.                                 begin
  608.                                     case Mode of
  609.  
  610.                                         FileMode: 
  611.                                             if (FileCount < 11) then
  612.                                                 begin
  613.                                                     SendFiles[FileCount] := TempString;
  614.                                                     FileCount := succ(FileCount)
  615.                                                 end;
  616.  
  617.                                         SendToMode: 
  618.                                             if (SendToCount < 11) then
  619.                                                 begin
  620.                                                     SendTo[SendToCount] := TempString;
  621.                                                     SendToCount := succ(SendToCount)
  622.                                                 end;
  623.  
  624.                                         OldiesMode: 
  625.                                             if (OldiesCount <= MaxOldies) then
  626.                                                 begin
  627.                                                     FilesProcessed[OldiesCount] := TempString;
  628.                                                     OldiesCount := succ(OldiesCount)
  629.                                                 end;
  630.  
  631.                                         otherwise
  632.                                             ;
  633.  
  634.                                     end;        {Case statement    }
  635.                                 end        {if not ((TempString[1] = '•') & (length(TempString) = 1))    }
  636.                             else
  637.                                 Mode := succ(Mode);
  638.                         end;        {    if (TempString[1] <> ';')    }
  639.                 end;        {    while (not AtEOF(InfoFile))    }
  640.         Err := FSClose(InfoFile);
  641.         FileCount := pred(FileCount);
  642.         SendToCount := pred(SendToCount);
  643.         OldiesCount := pred(OldiesCount)
  644.     end;
  645.  
  646. { ------------------------------------------------------ }
  647.  
  648.     procedure CheckForFiles;
  649.  
  650.         var
  651.             Counter, InfoFile, BackupFile, BulletCount: integer;
  652.             myPB: WDPBRec;
  653.             TempString, InfoName, BackupName: str255;
  654.  
  655.     begin
  656.         GetGenericPath;
  657.  
  658.       {get volume refnum}
  659.         WhereAt := Location;
  660.         MyPB.ioNamePtr := @WhereAt;
  661.         MyPB.ioCompletion := nil;
  662.         MyPB.ioVRefNum := 0;
  663.         MyPB.ioWDProcID := mySignature;
  664.         MyPB.ioWDDirID := 0;
  665.         Err := PBOpenWD(@MyPB, false);
  666.  
  667.         {get WDRefnum}
  668.         WhereAt := Location;
  669.         MyPB.ioNamePtr := @WhereAt;
  670.         MyPB.ioCompletion := nil;
  671.         MyPB.ioNamePtr := nil;
  672.         {MyPB.ioVRefNum from above}
  673.         MyPB.ioWDProcID := mySignature;
  674.         Err := PBOpenWD(@MyPB, false);
  675.  
  676.         ReadInfo;
  677.  
  678.         for Counter := 1 to OldiesCount do
  679.             begin
  680.                 TempString := FilesProcessed[Counter];
  681.                 Verify(TempString, MyPB);
  682.                 FilesProcessed[Counter] := TempString
  683.             end;
  684.  
  685.         for Counter := 1 to FileCount do
  686.             LookFor(SendFiles[Counter], MyPB);
  687.  
  688.         TempString := '';
  689.         InfoName := concat(Location, DataFileName);
  690.         BackupName := concat(InfoName, '.$');
  691.         BulletCount := 0;
  692.         Err := FSOpen(InfoName, vRefNum, InfoFile);
  693.         if Err = NoErr then
  694.             MakeTextFile(BackupName);
  695.         if Err = NoErr then
  696.             Err := FSOpen(BackupName, vRefNum, BackupFile);
  697.         if Err = NoErr then
  698.             repeat
  699.                 Err := ReadALine(InfoFile, TempString);
  700.                 if Err = NoErr then
  701.                     Err := WrLn(BackupFile, TempString);
  702.                 if (TempString[1] = '•') & (length(TempString) = 1) then
  703.                     BulletCount := succ(BulletCount);
  704.             until (BulletCount = 2) | AtEOF(InfoFile) | (Err <> NoErr);
  705.         for Counter := 1 to OldiesCount do
  706.             if (Err = NoErr) & (FilesProcessed[Counter] <> '') then
  707.                 Err := WrLn(BackupFile, FilesProcessed[Counter]);
  708.         Err := FSClose(BackupFile);
  709.         Err := FSClose(InfoFile);
  710.         if Err = NoErr then
  711.             Err := FSDelete(InfoName, vRefNum);
  712.         if Err = NoErr then
  713.             Err := Rename(BackupName, vRefNum, InfoName)
  714.     end;
  715.  
  716. { ------------------------------------------------------ }
  717.  
  718.     procedure SetUp;
  719.  
  720.     begin
  721.         if GetString(500) <> nil then
  722.             NextLaunch := GetString(500)^^;    {    Get next launch string from resource    }
  723.         if GetString(501) <> nil then
  724.             DataFileName := GetString(501)^^;    {Get data file string from resource    }
  725.         if GetString(502) <> nil then
  726.             Location := GetString(502)^^;    {Get location string from resource        }
  727.         if GetString(503) <> nil then
  728.             When := GetString(503)^^;        {Get when string from resource        }
  729.         if GetString(504) <> nil then
  730.             RegisterSTR := GetString(504)^^;    {Get registration string                }
  731.         Unreg := 'Not Registered';
  732.         VerifyRegistration;
  733.         ParamText(VERSION, '', '', '')
  734.     end;
  735.  
  736. { ------------------------------------------------------ }
  737.  
  738. begin
  739.     MaxApplZone;
  740.     SetUp;
  741.     if Button then
  742.         Configure            { If user is holding down the mouse button, reconfigure and end     }
  743.     else
  744.         begin
  745.             if (Unreg[14] = 'd') & (Unreg[1] = 'N') & (Unreg[3] = 't') & (Unreg[7] = 'g') & (Unreg[12] = 'r') then
  746.                 begin
  747.                     RunDialog := GetNewDialog(501, nil, POINTER(-1));
  748.                     SetPort(RunDialog);
  749.                     DrawDialog(RunDialog);
  750.                     HelloTabby;
  751.                     if (StringToDay(When) = EveryDay) | (StringToDay(When) = WhatDay) then
  752.                         CheckForFiles;
  753.                     myCloseWD;
  754.                     if (RunDialog <> nil) then
  755.                         DisposDialog(RunDialog);
  756.                     if NextLaunch <> '' then
  757.                         LaunchNextAppl
  758.                 end
  759.         end
  760. end.